<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Removes child from list of children</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="domnode.normalize.html">DOMNode::normalize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="domnode.replacechild.html">DOMNode::replaceChild</a></div>
 <div class="up"><a href="class.domnode.html">DOMNode</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="domnode.removechild" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DOMNode::removeChild</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">DOMNode::removeChild</span> &mdash; <span class="dc-title">
   Removes child from list of children
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-domnode.removechild-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span> <span class="methodname"><strong>DOMNode::removeChild</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.domnode.html" class="type DOMNode">DOMNode</a></span> <code class="parameter">$oldnode</code></span>
   )</div>

  <p class="para rdfs-comment">
   This functions removes a child from a list of children.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-domnode.removechild-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">oldnode</code></em></dt>

     <dd>

      <p class="para">
       The removed child.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-domnode.removechild-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   If the child could be removed the function returns the old child.
  </p>
 </div>

 <div class="refsect1 errors" id="refsect1-domnode.removechild-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   <dl>

    
     <dt>
<strong><code>DOM_NO_MODIFICATION_ALLOWED_ERR</code></strong></dt>

     <dd>

      <p class="para">
       Raised if this node is readonly.
      </p>
     </dd>

    
    
     <dt>
<strong><code>DOM_NOT_FOUND</code></strong></dt>

     <dd>

      <p class="para">
       Raised if <em><code class="parameter">oldnode</code></em> is not a child of this node.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-domnode.removechild-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   The following example will delete the <em>chapter</em> element of our XML document.
   <div class="example" id="example-5310">
    <p><strong>Example #1 Removing a child</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$doc&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DOMDocument</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">load</span><span style="color: #007700">(</span><span style="color: #DD0000">'book.xml'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$book&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">documentElement</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;we&nbsp;retrieve&nbsp;the&nbsp;chapter&nbsp;and&nbsp;remove&nbsp;it&nbsp;from&nbsp;the&nbsp;book<br /></span><span style="color: #0000BB">$chapter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$book</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getElementsByTagName</span><span style="color: #007700">(</span><span style="color: #DD0000">'chapter'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">item</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$oldchapter&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$book</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">removeChild</span><span style="color: #007700">(</span><span style="color: #0000BB">$chapter</span><span style="color: #007700">);<br /><br />echo&nbsp;</span><span style="color: #0000BB">$doc</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">saveXML</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!DOCTYPE book PUBLIC &quot;-//OASIS//DTD DocBook XML V4.1.2//EN&quot; 
          &quot;http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd&quot;&gt;
&lt;book id=&quot;listing&quot;&gt;
 &lt;title&gt;My lists&lt;/title&gt;
 
&lt;/book&gt;
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-domnode.removechild-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="domnode.appendchild.html" class="methodname" rel="rdfs-seeAlso">DOMNode::appendChild()</a> - Adds new child at the end of the children</span></li>
    <li class="member"><span class="methodname"><a href="domnode.replacechild.html" class="methodname" rel="rdfs-seeAlso">DOMNode::replaceChild()</a> - Replaces a child</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="domnode.normalize.html">DOMNode::normalize</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="domnode.replacechild.html">DOMNode::replaceChild</a></div>
 <div class="up"><a href="class.domnode.html">DOMNode</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
